<%@page import="com.situ.web.entity.Course"%>
<%@page import="java.util.ArrayList"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
<link rel="stylesheet" type="text/css" href="bootstrap-3.3.7-dist/css/bootstrap.css"/>
</head>
<body>
	<%
	   // jsp页面中内置了request对象，可以直接使用,类似于document可以直接使用
		ArrayList<Course> list = (ArrayList<Course>)request.getAttribute("list");
		// response
		session.setAttribute("name", "lisi");
		// application就是ServletContext
		application.setAttribute("name", "wangwu");
	%>
	
	
	<a class="btn btn-primary" href="<%=request.getContextPath()%>/student_insert.jsp">添加</a>
	<table class="table table-striped table-bordered table-hover table-condensed">
		<tr>
			<th>ID</th>
			<th>名字</th>
			<th>年龄</th>
			<th>删除</th>
			<th>修改</th>
		</tr>
		<%
			for (Course course : list) {
		%>
				<tr>
					<td><%=course.getId()%></td>
					<td><%=course.getName()%></td>
					<td><%=course.getCredit()%></td>
					<%-- <td><a href="<%=request.getContextPath()%>/deleteStudent?id=<%=student.getId()%>">删除</a></td> --%>
					<td><a href="javascript:void(0)" onclick="deleteById(<%=course.getId()%>)">删除</a></td>
					<td><a href="<%=request.getContextPath()%>/course?method=selectById&id=<%=course.getId()%>">修改</a></td>
					<!-- request.getContextPath() 返回当前项目名字 -->
				</tr>
		<%
			}
		%>
	</table>
	
	<script type="text/javascript">
		function deleteById(id) {
			var isDel = confirm("您确认要删除么？");
			if (isDel) {
				location.href = "/Java1912Web2/course?method=deleteById&id=" + id;
			}
		}
	</script>
</body>
</html>